package com.zhiyou100.action01;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author yang
 * @className Demo01
 * @packageName com.zhiyou100.action
 * @Description TODO 处理请求的类，需要实现接口 Controller，实现方法 handleRequest
 * @date 2020-08-20 15:03
 */
public class Demo02 implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 获取请求设置编码集
        request.setCharacterEncoding("utf-8");
        // 获取请求参数
        //final String sname = request.getParameter("sname");
        //final int sage = Integer.parseInt(request.getParameter("sage"));
        //System.out.println(sname + " ::: " + sage);

        // 创建 ModelAndView
        final ModelAndView modelAndView = new ModelAndView();
        // 设置 request 域属性
        modelAndView.addObject("message", "Demo02！");
        // 选择跳转页面
        modelAndView.setViewName("/test01/success.jsp");


        return modelAndView;
    }
}
